package com.wsoft.hr.pm.service.impl;

import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wsoft.hr.pm.entity.HrPmTargetEntity;
import com.wsoft.hr.pm.entity.HrPmTemplateTargetHisEntity;
import com.wsoft.hr.pm.manager.HrPmTargetManager;
import com.wsoft.hr.pm.manager.HrPmTemplateTargetHisManager;
import com.wsoft.hr.pm.mapper.HrPmTemplateTargetHisMapper;
import com.wsoft.hr.pm.query.template.his.HisInfoQuery;
import com.wsoft.hr.pm.service.IHrPmTemplateTargetHisService;
import com.wsoft.hr.pm.vo.target.TargetVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 指标库 服务实现类
 * </p>
 *
 * @author Z001
 * @since 2025年02月24日 18:26:47
 */
@Service
public class HrPmTemplateTargetHisServiceImpl extends ServiceImpl<HrPmTemplateTargetHisMapper, HrPmTemplateTargetHisEntity> implements IHrPmTemplateTargetHisService {

    @Resource
    private HrPmTemplateTargetHisManager templateTargetHisManager;
    @Resource
    private HrPmTargetManager targetManager;

    /**
     * 获取模版下指标详情
     * @param id
     * @return
     */
    @Override
    public TargetVO getHisInfo(HisInfoQuery query) {
        if(null != query.getId()){
            HrPmTemplateTargetHisEntity targetHisEntity = templateTargetHisManager.getById(query.getId());
           return Convert.convert(TargetVO.class, targetHisEntity);
        }
        HrPmTargetEntity targetEntity = targetManager.getById(query.getTargetId());
        return Convert.convert(TargetVO.class, targetEntity);

    }
}
